package io.hugetower.modules.pest.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

import io.hugetower.modules.pest.entity.CropPestDiseaseEntity;
import io.hugetower.modules.pest.service.CropPestDiseaseService;
import io.hugetower.common.utils.PageUtils;
import io.hugetower.common.utils.R;



/**
 * 
 *
 * @author fox
 * @email fox@gmail.com
 * @date 2024-04-14 07:54:39
 */
@RestController
@RequestMapping("pest/croppestdisease")
@Api(tags="")
public class CropPestDiseaseController {
    @Autowired
    private CropPestDiseaseService cropPestDiseaseService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ApiOperation("分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页码，从1开始", paramType = "query", required = true, dataType="int") ,
            @ApiImplicitParam(name = "limit", value = "每页显示记录数", paramType = "query",required = true, dataType="int")
        })
    //@RequiresPermissions("pest:croppestdisease:list")
    public R list(@ApiIgnore @RequestParam Map<String, Object> params, CropPestDiseaseEntity cropPestDiseaseEntity){
        PageUtils page = cropPestDiseaseService.queryPage(params, cropPestDiseaseEntity);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("pest:croppestdisease:info")
    public R info(@PathVariable("id") Long id){
		CropPestDiseaseEntity cropPestDisease = cropPestDiseaseService.getById(id);

        return R.ok().put("cropPestDisease", cropPestDisease);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("pest:croppestdisease:save")
    public R save(@RequestBody CropPestDiseaseEntity cropPestDisease){
		cropPestDiseaseService.save(cropPestDisease);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("pest:croppestdisease:update")
    public R update(@RequestBody CropPestDiseaseEntity cropPestDisease){
		cropPestDiseaseService.updateById(cropPestDisease);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("pest:croppestdisease:delete")
    public R delete(@RequestBody Long[] ids){
		cropPestDiseaseService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
